package com.hippo.core.service;

import com.alibaba.fastjson.JSONObject;
import com.hippo.core.dao.FieldMappingDao;
import com.hippo.core.util.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: hippo
 */
@Service
public class FieldMappingService {

    @Autowired
    private FieldMappingDao fieldMappingDao;

    public JSONObject getFieldMappingList(JSONObject jsonObject) {
        CommonUtil.fillPageParam(jsonObject);
        int count = fieldMappingDao.countFieldMapping(jsonObject);
        List<JSONObject> list = fieldMappingDao.getFieldMappingList(jsonObject);
        return CommonUtil.successPage(jsonObject, list, count);
    }

    public JSONObject addFieldMapping(JSONObject data) {
        return CommonUtil.response(fieldMappingDao.addFieldMapping(data));
    }

    public JSONObject updateFieldMapping(JSONObject data) {
        return CommonUtil.response(fieldMappingDao.updateFieldMapping(data));
    }

    public JSONObject deleteFieldMapping(Integer id) {
        return CommonUtil.response(fieldMappingDao.deleteFieldMapping(id));
    }
}
